package com.mashibing.rabbitmq_boot.config;

import org.springframework.amqp.core.*;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Classname RabbitMQConfig
 * @Description TODO
 * @Date 2022/4/21 11:10
 * @Created by 666
 */
@Configuration
public class HeaderConfig {
    public static final String EXCHANGE = "header-exchange";
    public static final String QUEUE = "header-queue";

    //创建header交换机
    @Bean
    public Exchange headerExchange() {
        return ExchangeBuilder.headersExchange(EXCHANGE).build();
    }

    //创建queue
    @Bean
    public Queue hearderQueue() {
        return QueueBuilder.durable(QUEUE).build();
    }

    //交换机绑定
    @Bean
    public Binding bootBing(Exchange headerExchange, Queue hearderQueue) {
        return BindingBuilder.bind(hearderQueue).to(headerExchange).with("").noargs();
    }
}
